package Gather.ExerciseDome;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

/**
 * ClassName:Exercise002
 * Package:Gather.ExerciseDome
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/21-20:23
 * @Version:v1.0
 */
public class Exercise002 {
    /*
     * 班级里有N个学生
     * 要求
     * 70%的概率随机到男生
     * 30%的概率随机到女生
     * */
    public static void main(String[] args) {
        //1111111 000  抽0或者1(抽到1随机男生,抽到0随机女生)

        //创建集合
        //定义集合
        ArrayList<Integer> list = new ArrayList<>();
        //添加数据
        Collections.addAll(list, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0);
        //打乱集合中的数据
        Collections.shuffle(list);
        //从list集合中随机抽取0或者1
        Random r = new Random();
        int index = r.nextInt(list.size());
        int number = list.get(index);
        //创建两个集合分别存储男生和女生的姓名
        ArrayList<String> boyList = new ArrayList<>();
        ArrayList<String> girlList = new ArrayList<>();
        Collections.addAll(boyList,"张鑫","郭永杰","梁二永","贾文玉","孙建明","郭佳伟","孙伟晔");
        Collections.addAll(girlList,"清清","慧慧","林黛玉","白骨精","媛媛","秀儿","大秀儿");
//        if (number==1){
//            Collections.shuffle(boyList);
//            System.out.println(boyList.get(0));
//        }else {
//            Collections.shuffle(girlList);
//            System.out.println(girlList.get(0));
//        }
        if (number==1){
            int boyIndex = r.nextInt(boyList.size());
            String name = boyList.get(boyIndex);
            System.out.println(name);
        }else {
            int girlIndex = r.nextInt(girlList.size());
            String name = girlList.get(girlIndex);
            System.out.println(name);
        }
    }
}
